package org.example.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.example.model.BlogInfo;

import java.util.List;

@Mapper
public interface BlogMapper {

    // delete_flag为 0 表示信息未被删除
    @Select("select * from blog where delete_flag = 0")
    List<BlogInfo> getBlogList();

    @Select("select * from blog where id = #{blogId}")
    BlogInfo getBlogById(Integer blogId);

    @Insert("insert into blog(title, content, user_id) values (#{title}, #{content}, #{userId})")
    Integer insertBlog(BlogInfo blogInfo);

    Integer updateBlog(BlogInfo blogInfo);
}
